<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
  	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  	<title>网站后台</title>
  	<link rel="stylesheet" href="<?php echo ADMIN_WEBURL ?>/public/global/layui/css/layui.css">
  	<link rel="stylesheet" href="<?php echo ADMIN_WEBURL ?>/public/admin/images/index.css">
  	<script type="text/javascript" src="/public/global/jquery/1.11.1/jquery.min.js" ></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  	<div class="layui-header">
    	<div class="layui-logo"><img src="/public/admin/images/admin_logo.png"/></div>
    	<ul class="layui-nav layui-layout-left">
      		<li class="layui-nav-item" >
      			<a class="nav" href="../" target="_blank">
	      			<span class="home iconfont icon-index"></span>
	      			<span>网站首页</span>
      			</a>
      		</li>
      		<li class="layui-nav-item"><a class="nav" href="javascript:void('0');" onclick="return system_checked('admin')"><span class="home iconfont icon-houtai"></span><span>主后台</span></a></li>
			<li class="layui-nav-item">
				<a class="nav" href="javascript:;"><span class="home iconfont icon-mokuai"></span><span>模块系统</span></a>
				<?php if($modular){ ?>
				<dl class="layui-nav-child">
					<?php foreach($modular AS $key=>$row) { ?>
					<dd><a href="javascript:void('0');" onclick="return system_checked('<?php echo $row['dir'] ?>')"><?php echo $row['name'] ?></a></dd>					
					<?php } ?>
				</dl>
				<?php } ?>
			</li>
			<li class="layui-nav-item">
				<a class="nav" href="javascript:;"><span class="home iconfont icon-chajian"></span><span>插件系统</span></a>
				<?php if($pluginDB){ ?>
				<dl class="layui-nav-child">
					<?php foreach($pluginDB AS $key=>$row) { ?>
					<dd><a href="javascript:void('0');" onclick="return system_checked('<?php echo $row['dir'] ?>')"><?php echo $row['name'] ?></a></dd>					
					<?php } ?>
				</dl>
				<?php } ?>
			</li>
			<li class="layui-nav-item"><a class="nav" id="upgrade_menu" href="javascript:void('0');" onclick="return system_checked('upgrade')"><span class="home iconfont icon-shengji"></span><span>在线升级</span></a></li>
    	</ul>
    	<script>
    		var menu='';
    		function system_checked(a){
    			if(!menu){
    				$('#admin').fadeOut("slow");
    				$('#'+a).fadeIn("slow");
    			}else{
    				$('#'+menu).fadeOut("slow");
    				$('#'+a).fadeIn("slow");	
    			}
    			menu=a;
    		}
    	</script>
		<ul class="layui-nav layui-layout-right">
			<li class="layui-nav-item">
				<a href="/admin/index/out">
					<span class="home iconfont icon-tuichu"></span>
	      			<span>退出</span>
				</a>
			</li>
		</ul>
	</div>
	<div class="layui-side layui-bg-black">
		<div class="layui-side-scroll">
			<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
			<ul class="layui-nav layui-nav-tree" id="admin">
				<li class="layui-nav-item layui-nav-itemed">
					<a href="javascript:;" class="menu">网站设置</a>
					<dl class="layui-nav-child">
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/setting/set" data-id="setting_set">网站设置</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/setting/article" data-id="setting_article">内容参数设置</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/setting/admin" data-id="setting_article">后台登陆限制</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/setting/gd" data-id="setting_gd">水印及缩略图设置</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/setting/stmp" data-id="setting_stmp">邮箱参数设置</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/homemenu/alllist" data-id="homemenu_alllist">网站导航菜单设置</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/setting/Shielding_words" data-id="Setting_Shielding_words">屏蔽词设置</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/Modular/alllist" data-id="Modular_alllist">模块管理</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/plugin/alllist" data-id="plugin_alllist">插件管理</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/hook/index" data-id="hook_index">钩子管理</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/setting/allcache" data-id="setting_allcache">一键更新全站缓存</a></dd>
					</dl>
				</li>
				<li class="layui-nav-item layui-nav-itemed">
					<a href="javascript:;" class="menu">云市场</a>
					<dl class="layui-nav-child">
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/cloud/modular" data-id="cloud_modular">模块市场</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/cloud/plugin" data-id="cloud/plugin">插件市场</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/cloud/hook" data-id="cloud/hook">钩子市场</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/cloud/tpl" data-id="cloud/tpl">模板市场</a></dd>
					</dl>
				</li>
				<li class="layui-nav-item">
					<a href="javascript:;" class="menu">权限管理</a>
					<dl class="layui-nav-child">
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/group/add" data-id="group_add">添加用户组</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/group/power" data-id="group_power">权限管理</a></dd>
					</dl>
				</li>
				<li class="layui-nav-item">
					<a href="javascript:;" class="menu">用户管理</a>
					<dl class="layui-nav-child">
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/user/add" data-id="user_add">添加用户</a></dd>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/user/alllist" data-id="user_list">用户管理</a></dd>
					</dl>
				</li>
			</ul>
			<ul class="layui-nav layui-nav-tree" id="upgrade" style="display: none;">
				<li class="layui-nav-item layui-nav-itemed">
				<a href="javascript:;">升级检测</a>
				<dl class="layui-nav-child">
					<dd><a href="javascript:void('0')" id="upgrade_all" class="site-active" data-url="/admin/upgrade/all" data-id="upgrade_all">全部检测</a></dd>
					<dd><a href="javascript:void('0')" class="site-active" data-url="/admin/upgrade/mvc" data-id="upgrade_mvc">只检测主程序</a></dd>
					<dd><a href="javascript:void('0')" class="site-active" data-url="/admin/upgrade/modular" data-id="upgrade_modular">只检测模块</a></dd>
					<dd><a href="javascript:void('0')" class="site-active" data-url="/admin/upgrade/plugin" data-id="upgrade_plugin">只检测插件</a></dd>
				</dl>
				</li>
			</ul>
			<?php foreach($Modular_DB AS $key=>$RS) {?>
			<ul class="layui-nav layui-nav-tree" id="<?php echo $RS[dir] ?>" style="display: none;">
				<?php foreach($RS['rute']['POWER'] AS $_key=>$RSS) { ?>
					<?php if($_key=='upfile') continue?>
					<?php if($RSS['list']) { ?>
						<?php foreach($RSS['list'] AS $__key=>$_RSS){?>
						<li class="layui-nav-item layui-nav-itemed">
							<a href="javascript:;" class="menu"><?php ECHO $_RSS[name] ?></a>
							<dl class="layui-nav-child">
							<?php foreach($_RSS['power'] AS $___key=>$__RSS) { ?>
								<?php 
									if($__RSS[if_show]){ 
										$__RSS['class'] ? $class=$__RSS['class']: $class= $_key;
										$__RSS['method'] ? $method = $__RSS['method'] : $method = $___key;
								?>
									
									<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/index/modular/<?php echo $RS[dir].'/'.$class.'/'.$method.$_RSS['parameter'] ?>" data-id="<?PHP echo $RS[dir].'_'.$__key.'_'.$___key.$_RSS['parameter'] ?>"><?PHP echo $__RSS[name] ?></a></dd>
								<?php } ?>
							<?php } ?>
							</dl>
						</li>
						<?php } ?>
					<?php }else{ ?>
						<li class="layui-nav-item layui-nav-itemed">
							<a href="javascript:;" class="menu"><?php ECHO $RSS[name] ?></a>
							<dl class="layui-nav-child">
							<?php foreach($RSS['power'] AS $key_=>$_RSS) { ?>
								<?php
									if($_RSS[if_show]){
										$_RSS['class'] ? $class=$_RSS['class']: $class= $_key;
										$_RSS['method'] ? $method = $_RSS['method'] : $method = $key_;
								 ?>
										<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/index/modular/<?php echo $RS[dir].'/'.$class.'/'.$method .$_RSS['parameter']?>" data-id="<?PHP echo $RS[dir].'_'.$_key.'_'.$key_ .$_RSS['parameter']?>"><?PHP echo $_RSS[name] ?></a></dd>
								<?php } ?>
							<?php } ?>
							</dl>
						</li>
					<?php } ?>
				<?php } ?>
			</ul>
			<?php } ?>
			<?php foreach($pluginDB AS $key=>$RS) { ?>
			<ul class="layui-nav layui-nav-tree" id="<?php echo $RS[dir] ?>" style="display: none;">
				<?php foreach($RS['rute']['POWER'] AS $_key=>$RSS) { ?>
				<li class="layui-nav-item layui-nav-itemed">
					<a href="javascript:;" class="menu"><?php ECHO $RSS[name] ?></a>
					<dl class="layui-nav-child">
					<?php foreach($RSS['power'] AS $key_=>$_RSS) { ?>
						<?php if($_RSS[if_show]){ ?>
						<dd><a href="javascript:void('0')" class=" site-active" data-url="/admin/index/plugin/<?php echo $RS[dir].'/'.$_key.'/'.$key_ ?>" data-id="<?PHP echo $RS[dir].'_'.$_key.'_'.$key_ ?>"><?PHP echo $_RSS[name] ?></a></dd>
						<?php } ?>
					<?php } ?>
					</dl>
				</li>
				<?php } ?>
			</ul>
			<?php } ?>
		</div>
	</div>
	<div class="layui-body">
		<div class="layui-tab layui-side" lay-filter="Menu" lay-allowclose="true">
			<ul class="layui-tab-title">
			    <li class="layui-this" lay-id="setting_map" id="setting_map">控制面板</li>
			</ul>
			<div class="layui-tab-content">
			    <div class="layui-tab-item layui-show"><iframe  src="/admin/index/map/"  ></iframe></div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="/public/global/layui/layui.js"></script>
<script>
	layui.use(['element'], function(){
		var $ = layui.jquery
		,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
		var active = {
		    tabAdd: function(){
		    	var a=$(".layui-tab-title").children('li')
		    	for(i=0;i< a.length ;i++){
		    		if($(this).data('id')===a[i].getAttribute("lay-id")){
		    			document.getElementById('iframe_'+$(this).data('id')).src=$(this).data('url');
		    			element.tabChange('Menu', $(this).data('id')); //切换到：用户管理
		    			return false;
		    		}
		    	}
		      	//新增一个Tab项
			    element.tabAdd('Menu', {
			        title: this.innerHTML
			        ,content: '<iframe id="iframe_'+$(this).data('id')+'" src="'+$(this).data('url')+'"></iframe>'
			        ,id: $(this).data('id') //实际使用一般是规定好的id，这里以时间戳模拟下
			    })
		       	element.tabChange('Menu', $(this).data('id')); //切换到：用户管理
		       	//iframe自适应
			    $(window).on('resize', function () {
			        var content = $('.layui-side .layui-tab-content');
			        content.height($(this).height() - 147);
			        content.find('iframe').each(function () {
			            $(this).height(content.height());
			            //console.log(content.height());
			        });
			    }).resize();
		    }
		    
		};
		$('#setting_map i').hide();
		$('.site-active').on('click', function(){
		    var othis = $(this);
		    active['tabAdd'] ? active['tabAdd'].call(this, othis) : '';
		});
		show_tab();
		function show_tab(){
			var content = $('.layui-side .layui-tab-content');
			content.height($(this).height() - 147);
			content.find('iframe').each(function () {
				$(this).height(content.height());
			});
		}
		
	});
	function upgarde(){
		$('#upgrade_menu').click();
	    $('#upgrade_all').click();
	}
</script>
</body>
</html>
